package com.ihg.hiex.admin.web.controller.session.during;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttribute;
import org.springframework.web.servlet.ModelAndView;

import com.demo2do.core.entity.result.HttpResult;
import com.demo2do.core.utils.CollectionUtils;
import com.demo2do.core.web.interceptor.MenuSetting;
import com.demo2do.core.web.resolver.Preloading;
import com.ihg.hiex.admin.Constants;
import com.ihg.hiex.admin.entity.dto.CalibrationAnchorScoreMapper;
import com.ihg.hiex.admin.entity.dto.CalibrationScore;
import com.ihg.hiex.admin.entity.security.Login;
import com.ihg.hiex.admin.service.account.AssessorService;
import com.ihg.hiex.admin.service.account.DelegateService;
import com.ihg.hiex.admin.service.session.CareerWorkService;
import com.ihg.hiex.admin.service.session.SessionDuringService;
import com.ihg.hiex.admin.service.session.SessionMeetingService;
import com.ihg.hiex.admin.service.session.SessionParticipatorService;
import com.ihg.hiex.admin.service.session.SessionService;
import com.ihg.hiex.admin.service.session.SessionTaskService;
import com.ihg.hiex.admin.web.resolver.Secure;
import com.ihg.hiex.entity.session.Session;
import com.ihg.hiex.entity.session.after.SessionReport;
import com.ihg.hiex.entity.session.before.delegatework.DelegateCareerGoals;
import com.ihg.hiex.entity.session.before.delegatework.DelegateSelfReflection;
import com.ihg.hiex.entity.session.before.delegatework.DelegateWorkDevelopActivity;
import com.ihg.hiex.entity.session.before.delegatework.DelegateWorkEducation;
import com.ihg.hiex.entity.session.before.delegatework.DelegateWorkFuturePosition;
import com.ihg.hiex.entity.session.before.delegatework.DelegateWorkLicense;
import com.ihg.hiex.entity.session.before.delegatework.DelegateWrokExperience;
import com.ihg.hiex.entity.session.before.delegatework.DelegateWrokRecord;
import com.ihg.hiex.entity.session.before.delegatework.DelegateWrokTraining;
import com.ihg.hiex.entity.session.before.test.PreWorkAssignment;
import com.ihg.hiex.entity.session.during.SessionAnchorScore;
import com.ihg.hiex.entity.session.during.SessionCalibration;
import com.ihg.hiex.entity.session.during.SessionCalibrationAnchorScore;
import com.ihg.hiex.entity.session.during.SessionCalibrationComment;
import com.ihg.hiex.entity.session.during.SessionCalibrationCompetency;
import com.ihg.hiex.entity.session.during.SessionCalibrationRecommendation;
import com.ihg.hiex.entity.session.during.SessionCompetencyScore;
import com.ihg.hiex.entity.session.during.SessionExercise;
import com.ihg.hiex.entity.session.during.SessionInBasket;
import com.ihg.hiex.entity.session.during.SessionInBasketAnswer;
import com.ihg.hiex.entity.session.meeting.SessionMeeting;
import com.ihg.hiex.entity.session.participator.SessionParticipator;
import com.ihg.hiex.entity.session.participator.Type;
import com.ihg.hiex.entity.session.task.SessionTask;
import com.ihg.hiex.entity.session.task.Status;
import com.ihg.hiex.entity.user.Assessor;
import com.ihg.hiex.entity.user.Delegate;
import com.ihg.hiex.entity.user.DelegateAttribute;

/**
 * 
 * @author dan
 *
 */
@Controller
@RequestMapping("/sessions/{sessionId}/peer-calibrations")
@MenuSetting("menu-sessions")
public class PeerCalibrationController {
    
    private static final Logger logger = LoggerFactory.getLogger(PeerCalibrationController.class);
    
    @Autowired
    private SessionService sessionService;
    
    @Autowired
    private SessionDuringService sessionDuringService;
    
    @Autowired
    private SessionParticipatorService sessionParticipatorService;
    
    @Autowired
    private SessionTaskService sessionTaskService;
    
    @Autowired
    private AssessorService assessorService;
    
    @Autowired
    private SessionMeetingService sessionMeetingService;
    
    @Autowired
    private DelegateService delegateService;
    
    @Autowired
    private CareerWorkService careerWorkService;
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param supervisor
     * @return
     */
    @SuppressWarnings("unchecked")
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "", method = RequestMethod.GET)
    public ModelAndView list(@Secure Login login, @PathVariable("sessionId") Long sessionId, @RequestParam(name = "supervisor", required = false) Boolean supervisor) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-list");
        
        Session session = sessionService.load(sessionId);
        modelAndView.addObject("session", session);
        
        // list assessor subgroup's delegates
        List<SessionParticipator> sessionParticipators = sessionParticipatorService.list(session);
        List<Long> delegateIds = CollectionUtils.extractPropertyList(sessionParticipators, "delegateId");
        
        // load meeting
        SessionMeeting sessionMeeting = sessionMeetingService.load(session, "Peer Calibration", login.getId());
        modelAndView.addObject("sessionMeeting", sessionMeeting);
        
        // list sessionCalibration by delegates
        List<SessionCalibration> sessionCalibrations = sessionDuringService.listSessionCalibration(session, delegateIds);
        modelAndView.addObject("sessionCalibrations", sessionCalibrations);
        
        // list sessionCalibrationCompetencies
        Map<String, Map<String, SessionCalibrationCompetency>> sessionCalibrationCompetencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibrations);
        modelAndView.addObject("sessionCalibrationCompetencies", sessionCalibrationCompetencies);
        
        // load sessionCalibrationComment
        Map<String, SessionCalibrationComment> sessionCalibrationComments = sessionDuringService.listSessionCalibrationComment(sessionCalibrations);
        modelAndView.addObject("sessionCalibrationComments", sessionCalibrationComments);
        
        // load sessionCalibrationRecommendation
        Map<String, SessionCalibrationRecommendation> sessionCalibrationRecommendations = sessionDuringService.listSessionCalibrationRecommendation(sessionCalibrations);
        modelAndView.addObject("sessionCalibrationRecommendations", sessionCalibrationRecommendations);
        
        List<Delegate> delegates = CollectionUtils.extractPropertyList(sessionCalibrations, "delegate");
        Map<Long, Status> reportTaskStatus = sessionTaskService.listCalibrationReportStatus(delegates, session, Type.ASSESSOR, new String[]{"Peer Calibration Competency", "Peer Calibration Comments", "Peer Calibration Recommendation"}, "Peer Calibration");
        modelAndView.addObject("reportTaskStatus", reportTaskStatus);

        Map<Long, Status> reportSubmitStatus = sessionTaskService.listCalibrationReportStatus(delegates, session, Type.ASSESSOR, new String[]{"Peer Calibration Report"}, "Peer Calibration");
        modelAndView.addObject("reportSubmitStatus", reportSubmitStatus);
        
        modelAndView.addObject("supervisor", supervisor == null ? false : supervisor);
        
        return modelAndView;
        
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param subgroup
     * @return
     */
    @SuppressWarnings("unchecked")
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "", method = RequestMethod.GET, params = "subgroup")
    public ModelAndView facilitatorList(@Secure Login login,
                                        @PathVariable("sessionId") Long sessionId,
                                        @RequestParam("subgroup") String subgroup) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-list");
        
        Session session = sessionService.load(sessionId);
        
        // list assessor subgroup's delegates
        List<SessionParticipator> sessionParticipators = sessionParticipatorService.list(session, subgroup);
        List<Long> delegateIds = CollectionUtils.extractPropertyList(sessionParticipators, "delegateId");
        
        // list sessionCalibration by delegates
        List<SessionCalibration> sessionCalibrations = sessionDuringService.listSessionCalibration(session, delegateIds);
        modelAndView.addObject("sessionCalibrations", sessionCalibrations);
        
        // list sessionCalibrationCompetencies
        Map<String, Map<String, SessionCalibrationCompetency>> sessionCalibrationCompetencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibrations);
        modelAndView.addObject("sessionCalibrationCompetencies", sessionCalibrationCompetencies);
        
        // load sessionCalibrationComment
        Map<String, SessionCalibrationComment> sessionCalibrationComments = sessionDuringService.listSessionCalibrationComment(sessionCalibrations);
        modelAndView.addObject("sessionCalibrationComments", sessionCalibrationComments);
        
        // load sessionCalibrationRecommendation
        Map<String, SessionCalibrationRecommendation> sessionCalibrationRecommendations = sessionDuringService.listSessionCalibrationRecommendation(sessionCalibrations);
        modelAndView.addObject("sessionCalibrationRecommendations", sessionCalibrationRecommendations);
        
        List<Delegate> delegates = CollectionUtils.extractPropertyList(sessionCalibrations, "delegate");
        Map<Long, Status> reportTaskStatus = sessionTaskService.listCalibrationReportStatus(delegates, session, Type.ASSESSOR, new String[]{"Peer Calibration Competency", "Peer Calibration Comments", "Peer Calibration Recommendation"}, "Peer Calibration");
        modelAndView.addObject("reportTaskStatus", reportTaskStatus);
        
        modelAndView.addObject("session", session);
        modelAndView.addObject("subgroup", subgroup);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting("submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/drive-result", method = RequestMethod.GET)
    public ModelAndView dr(@Secure Login login,
                                    @PathVariable("sessionId") Long sessionId,
                                    @PathVariable("calibrationId") Long calibrationId,
                                    @RequestParam(name = "subgroup", required = false) String subgroup) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-drive-result");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        SessionCalibrationCompetency sessionCalibrationCompetency = sessionDuringService.loadSessionCalibrationCompetency(sessionCalibration, "Drive Result");
        modelAndView.addObject("sessionCalibrationCompetency", sessionCalibrationCompetency);
        
        // list sessionCalibrationAnchorScore
        List<SessionCalibrationAnchorScore> sessionCalibrationAnchorScores = sessionDuringService.listCalibrationAnchorScore(sessionCalibrationCompetency);
        modelAndView.addObject("sessionCalibrationAnchorScores", sessionCalibrationAnchorScores);
        
        Session session = sessionCalibration.getSession();
        modelAndView.addObject("session", session);

        modelAndView.addObject("leadAssessor", sessionCalibration.getLeadAssessor());
        modelAndView.addObject("peerAssessor", sessionCalibration.getPeerAssessor());
        
        Delegate delegate = sessionCalibration.getDelegate();
        modelAndView.addObject("delegate", delegate);
        
        // list meeting's anchor score
        Map<String, List<SessionAnchorScore>> meetingScores = sessionDuringService.listMeetingAnchorScores(session, delegate, "Drive Results");
        modelAndView.addObject("meetingScores", meetingScores);
        modelAndView.addObject("oltMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("OLT Meeting")));
        
        // list inBasket's anchor score
        List<SessionAnchorScore> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, delegate, "Drive Results");
        modelAndView.addObject("inBasketScores", inBasketScores);
        modelAndView.addObject("inBasketScore", sessionDuringService.generateMeetingScore(inBasketScores));
        
//        // list meeting's anchor score
//        Map<String, Map<String, Map<String, SessionAnchorScore>>> meetingScores = sessionDuringService.listMeetingAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("meetingScores", meetingScores);
//        
//        // list inBasket's anchor score
//        Map<String, Map<String, SessionAnchorScore>> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("inBasketScores", inBasketScores);
//        
//        // get competency scores
//        Map<String, List<SessionAnchorScore>> meetingScore = sessionDuringService.listMeetingAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, List<SessionAnchorScore>> inBasketScore = sessionDuringService.listInBasketAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, SessionAnchorScoreType> competencyScores = calibrationHandler.generateAnchorScore(meetingScore, inBasketScore);
//        modelAndView.addObject("competencyScores", competencyScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        SessionReport sessionReport = sessionDuringService.loadSessionReport(session, delegate);
        modelAndView.addObject("sessionReport", sessionReport);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting("submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/work-collaboratively", method = RequestMethod.GET)
    public ModelAndView wc(@Secure Login login,
                                    @PathVariable("sessionId") Long sessionId,
                                    @PathVariable("calibrationId") Long calibrationId,
                                    @RequestParam(name = "subgroup", required = false) String subgroup) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-work-collaboratively");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        SessionCalibrationCompetency sessionCalibrationCompetency = sessionDuringService.loadSessionCalibrationCompetency(sessionCalibration, "Work Collaboratively");
        modelAndView.addObject("sessionCalibrationCompetency", sessionCalibrationCompetency);
        
        // list sessionCalibrationAnchorScore
        List<SessionCalibrationAnchorScore> sessionCalibrationAnchorScores = sessionDuringService.listCalibrationAnchorScore(sessionCalibrationCompetency);
        modelAndView.addObject("sessionCalibrationAnchorScores", sessionCalibrationAnchorScores);
        
        Session session = sessionCalibration.getSession();
        modelAndView.addObject("session", session);

        modelAndView.addObject("leadAssessor", sessionCalibration.getLeadAssessor());
        modelAndView.addObject("peerAssessor", sessionCalibration.getPeerAssessor());
        
        Delegate delegate = sessionCalibration.getDelegate();
        modelAndView.addObject("delegate", delegate);
        
        // list meeting's anchor score
        Map<String, List<SessionAnchorScore>> meetingScores = sessionDuringService.listMeetingAnchorScores(session, delegate, "Work Collaboratively");
        modelAndView.addObject("meetingScores", meetingScores);
        modelAndView.addObject("colleagueMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("Colleague Meeting")));
        modelAndView.addObject("guestMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("Guest Meeting")));
        
        // list inBasket's anchor score
//        List<SessionAnchorScore> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, delegate, "Work Collaboratively");
//        modelAndView.addObject("inBasketScores", inBasketScores);
        
//        // list meeting's anchor score
//        Map<String, Map<String, Map<String, SessionAnchorScore>>> meetingScores = sessionDuringService.listMeetingAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("meetingScores", meetingScores);
//        
//        // list inBasket's anchor score
//        Map<String, Map<String, SessionAnchorScore>> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("inBasketScores", inBasketScores);
//        
//        // get competency scores
//        Map<String, List<SessionAnchorScore>> meetingScore = sessionDuringService.listMeetingAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, List<SessionAnchorScore>> inBasketScore = sessionDuringService.listInBasketAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, SessionAnchorScoreType> competencyScores = calibrationHandler.generateAnchorScore(meetingScore, inBasketScore);
//        modelAndView.addObject("competencyScores", competencyScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        SessionReport sessionReport = sessionDuringService.loadSessionReport(session, delegate);
        modelAndView.addObject("sessionReport", sessionReport);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting("submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/champion-change", method = RequestMethod.GET)
    public ModelAndView cc(@Secure Login login,
                               @PathVariable("sessionId") Long sessionId,
                               @PathVariable("calibrationId") Long calibrationId,
                               @RequestParam(name = "subgroup", required = false) String subgroup) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-champion-change");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        SessionCalibrationCompetency sessionCalibrationCompetency = sessionDuringService.loadSessionCalibrationCompetency(sessionCalibration, "Champion Change");
        modelAndView.addObject("sessionCalibrationCompetency", sessionCalibrationCompetency);
        
        // list sessionCalibrationAnchorScore
        List<SessionCalibrationAnchorScore> sessionCalibrationAnchorScores = sessionDuringService.listCalibrationAnchorScore(sessionCalibrationCompetency);
        modelAndView.addObject("sessionCalibrationAnchorScores", sessionCalibrationAnchorScores);
        
        Session session = sessionCalibration.getSession();
        modelAndView.addObject("session", session);

        modelAndView.addObject("leadAssessor", sessionCalibration.getLeadAssessor());
        modelAndView.addObject("peerAssessor", sessionCalibration.getPeerAssessor());
        
        Delegate delegate = sessionCalibration.getDelegate();
        modelAndView.addObject("delegate", delegate);
        
        // list meeting's anchor score
        Map<String, List<SessionAnchorScore>> meetingScores = sessionDuringService.listMeetingAnchorScores(session, delegate, "Champion Change");
        modelAndView.addObject("meetingScores", meetingScores);
        modelAndView.addObject("oltMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("OLT Meeting")));
        
        // list inBasket's anchor score
//        List<SessionAnchorScore> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, delegate, "Champion Change");
//        modelAndView.addObject("inBasketScores", inBasketScores);
        
//        // list meeting's anchor score
//        Map<String, Map<String, Map<String, SessionAnchorScore>>> meetingScores = sessionDuringService.listMeetingAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("meetingScores", meetingScores);
//        
//        // list inBasket's anchor score
//        Map<String, Map<String, SessionAnchorScore>> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("inBasketScores", inBasketScores);
//        
//        // get competency scores
//        Map<String, List<SessionAnchorScore>> meetingScore = sessionDuringService.listMeetingAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, List<SessionAnchorScore>> inBasketScore = sessionDuringService.listInBasketAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, SessionAnchorScoreType> competencyScores = calibrationHandler.generateAnchorScore(meetingScore, inBasketScore);
//        modelAndView.addObject("competencyScores", competencyScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        SessionReport sessionReport = sessionDuringService.loadSessionReport(session, delegate);
        modelAndView.addObject("sessionReport", sessionReport);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting("submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/owner-relations", method = RequestMethod.GET)
    public ModelAndView or(@Secure Login login,
                             @PathVariable("sessionId") Long sessionId,
                             @PathVariable("calibrationId") Long calibrationId,
                             @RequestParam(name = "subgroup", required = false) String subgroup) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-owner-relations");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        SessionCalibrationCompetency sessionCalibrationCompetency = sessionDuringService.loadSessionCalibrationCompetency(sessionCalibration, "Owner Relations");
        modelAndView.addObject("sessionCalibrationCompetency", sessionCalibrationCompetency);
        
        // list sessionCalibrationAnchorScore
        List<SessionCalibrationAnchorScore> sessionCalibrationAnchorScores = sessionDuringService.listCalibrationAnchorScore(sessionCalibrationCompetency);
        modelAndView.addObject("sessionCalibrationAnchorScores", sessionCalibrationAnchorScores);
        
        Session session = sessionCalibration.getSession();
        modelAndView.addObject("session", session);

        modelAndView.addObject("leadAssessor", sessionCalibration.getLeadAssessor());
        modelAndView.addObject("peerAssessor", sessionCalibration.getPeerAssessor());
        
        Delegate delegate = sessionCalibration.getDelegate();
        modelAndView.addObject("delegate", delegate);
        
        // list meeting's anchor score
        Map<String, List<SessionAnchorScore>> meetingScores = sessionDuringService.listMeetingAnchorScores(session, delegate, "Owner Relations");
        modelAndView.addObject("meetingScores", meetingScores);
        modelAndView.addObject("ownerMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("Owner Meeting")));
        
        // list inBasket's anchor score
        List<SessionAnchorScore> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, delegate, "Owner Relations");
        modelAndView.addObject("inBasketScores", inBasketScores);
        modelAndView.addObject("inBasketScore", sessionDuringService.generateMeetingScore(inBasketScores));
        
//        // list meeting's anchor score
//        Map<String, Map<String, Map<String, SessionAnchorScore>>> meetingScores = sessionDuringService.listMeetingAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("meetingScores", meetingScores);
//        
//        // list inBasket's anchor score
//        Map<String, Map<String, SessionAnchorScore>> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("inBasketScores", inBasketScores);
//        
//        // get competency scores
//        Map<String, List<SessionAnchorScore>> meetingScore = sessionDuringService.listMeetingAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, List<SessionAnchorScore>> inBasketScore = sessionDuringService.listInBasketAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, SessionAnchorScoreType> competencyScores = calibrationHandler.generateAnchorScore(meetingScore, inBasketScore);
//        modelAndView.addObject("competencyScores", competencyScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        SessionReport sessionReport = sessionDuringService.loadSessionReport(session, delegate);
        modelAndView.addObject("sessionReport", sessionReport);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting("submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/lead-and-develop", method = RequestMethod.GET)
    public ModelAndView ld(@Secure Login login,
                             @PathVariable("sessionId") Long sessionId,
                             @PathVariable("calibrationId") Long calibrationId,
                             @RequestParam(name = "subgroup", required = false) String subgroup) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-lead-and-develop");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        SessionCalibrationCompetency sessionCalibrationCompetency = sessionDuringService.loadSessionCalibrationCompetency(sessionCalibration, "Lead and Development");
        modelAndView.addObject("sessionCalibrationCompetency", sessionCalibrationCompetency);
        
        // list sessionCalibrationAnchorScore
        List<SessionCalibrationAnchorScore> sessionCalibrationAnchorScores = sessionDuringService.listCalibrationAnchorScore(sessionCalibrationCompetency);
        modelAndView.addObject("sessionCalibrationAnchorScores", sessionCalibrationAnchorScores);
        
        Session session = sessionCalibration.getSession();
        modelAndView.addObject("session", session);

        modelAndView.addObject("leadAssessor", sessionCalibration.getLeadAssessor());
        modelAndView.addObject("peerAssessor", sessionCalibration.getPeerAssessor());
        
        Delegate delegate = sessionCalibration.getDelegate();
        modelAndView.addObject("delegate", delegate);
        
        // list meeting's anchor score
        Map<String, List<SessionAnchorScore>> meetingScores = sessionDuringService.listMeetingAnchorScores(session, delegate, "Lead and Development");
        modelAndView.addObject("meetingScores", meetingScores);
        modelAndView.addObject("colleagueMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("Colleague Meeting")));
        modelAndView.addObject("oltMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("OLT Meeting")));
        
        // list inBasket's anchor score
        List<SessionAnchorScore> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, delegate, "Lead and Development");
        modelAndView.addObject("inBasketScores", inBasketScores);
        modelAndView.addObject("inBasketScore", sessionDuringService.generateMeetingScore(inBasketScores));
        
//        // list meeting's anchor score
//        Map<String, Map<String, Map<String, SessionAnchorScore>>> meetingScores = sessionDuringService.listMeetingAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("meetingScores", meetingScores);
//        
//        // list inBasket's anchor score
//        Map<String, Map<String, SessionAnchorScore>> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("inBasketScores", inBasketScores);
//        
//        // get competency scores
//        Map<String, List<SessionAnchorScore>> meetingScore = sessionDuringService.listMeetingAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, List<SessionAnchorScore>> inBasketScore = sessionDuringService.listInBasketAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, SessionAnchorScoreType> competencyScores = calibrationHandler.generateAnchorScore(meetingScore, inBasketScore);
//        modelAndView.addObject("competencyScores", competencyScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        SessionReport sessionReport = sessionDuringService.loadSessionReport(session, delegate);
        modelAndView.addObject("sessionReport", sessionReport);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting("submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/operations-management", method = RequestMethod.GET)
    public ModelAndView om(@Secure Login login,
                             @PathVariable("sessionId") Long sessionId,
                             @PathVariable("calibrationId") Long calibrationId,
                             @RequestParam(name = "subgroup", required = false) String subgroup) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-operations-management");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        SessionCalibrationCompetency sessionCalibrationCompetency = sessionDuringService.loadSessionCalibrationCompetency(sessionCalibration, "Operations Management");
        modelAndView.addObject("sessionCalibrationCompetency", sessionCalibrationCompetency);
        
        // list sessionCalibrationAnchorScore
        List<SessionCalibrationAnchorScore> sessionCalibrationAnchorScores = sessionDuringService.listCalibrationAnchorScore(sessionCalibrationCompetency);
        modelAndView.addObject("sessionCalibrationAnchorScores", sessionCalibrationAnchorScores);
        
        Session session = sessionCalibration.getSession();
        modelAndView.addObject("session", session);

        modelAndView.addObject("leadAssessor", sessionCalibration.getLeadAssessor());
        modelAndView.addObject("peerAssessor", sessionCalibration.getPeerAssessor());
        
        Delegate delegate = sessionCalibration.getDelegate();
        modelAndView.addObject("delegate", delegate);
        
        // list meeting's anchor score
        Map<String, List<SessionAnchorScore>> meetingScores = sessionDuringService.listMeetingAnchorScores(session, delegate, "Operations Management");
        modelAndView.addObject("meetingScores", meetingScores);
        modelAndView.addObject("guestMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("Guest Meeting")));
        modelAndView.addObject("oltMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("OLT Meeting")));
        
        // list inBasket's anchor score
        List<SessionAnchorScore> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, delegate, "Operations Management");
        modelAndView.addObject("inBasketScores", inBasketScores);
        modelAndView.addObject("inBasketScore", sessionDuringService.generateMeetingScore(inBasketScores));
        
//        // list meeting's anchor score
//        Map<String, Map<String, Map<String, SessionAnchorScore>>> meetingScores = sessionDuringService.listMeetingAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("meetingScores", meetingScores);
//        
//        // list inBasket's anchor score
//        Map<String, Map<String, SessionAnchorScore>> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("inBasketScores", inBasketScores);
//        
//        // get competency scores
//        Map<String, List<SessionAnchorScore>> meetingScore = sessionDuringService.listMeetingAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, List<SessionAnchorScore>> inBasketScore = sessionDuringService.listInBasketAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, SessionAnchorScoreType> competencyScores = calibrationHandler.generateAnchorScore(meetingScore, inBasketScore);
//        modelAndView.addObject("competencyScores", competencyScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        SessionReport sessionReport = sessionDuringService.loadSessionReport(session, delegate);
        modelAndView.addObject("sessionReport", sessionReport);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting("submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/revenue-maximisation", method = RequestMethod.GET)
    public ModelAndView rm(@Secure Login login,
                             @PathVariable("sessionId") Long sessionId,
                             @PathVariable("calibrationId") Long calibrationId,
                             @RequestParam(name = "subgroup", required = false) String subgroup) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-revenue-maximisation");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        SessionCalibrationCompetency sessionCalibrationCompetency = sessionDuringService.loadSessionCalibrationCompetency(sessionCalibration, "Revenue Maximisation");
        modelAndView.addObject("sessionCalibrationCompetency", sessionCalibrationCompetency);
        
        // list sessionCalibrationAnchorScore
        List<SessionCalibrationAnchorScore> sessionCalibrationAnchorScores = sessionDuringService.listCalibrationAnchorScore(sessionCalibrationCompetency);
        modelAndView.addObject("sessionCalibrationAnchorScores", sessionCalibrationAnchorScores);
        
        Session session = sessionCalibration.getSession();
        modelAndView.addObject("session", session);

        modelAndView.addObject("leadAssessor", sessionCalibration.getLeadAssessor());
        modelAndView.addObject("peerAssessor", sessionCalibration.getPeerAssessor());
        
        Delegate delegate = sessionCalibration.getDelegate();
        modelAndView.addObject("delegate", delegate);
        
        // list meeting's anchor score
        Map<String, List<SessionAnchorScore>> meetingScores = sessionDuringService.listMeetingAnchorScores(session, delegate, "Revenue Maximisation");
        modelAndView.addObject("meetingScores", meetingScores);
        modelAndView.addObject("colleagueMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("Colleague Meeting")));
        modelAndView.addObject("oltMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("OLT Meeting")));
        
        // list inBasket's anchor score
//        List<SessionAnchorScore> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, delegate, "Revenue Maximisation");
//        modelAndView.addObject("inBasketScores", inBasketScores);
        
//        // list meeting's anchor score
//        Map<String, Map<String, Map<String, SessionAnchorScore>>> meetingScores = sessionDuringService.listMeetingAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("meetingScores", meetingScores);
//        
//        // list inBasket's anchor score
//        Map<String, Map<String, SessionAnchorScore>> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("inBasketScores", inBasketScores);
//        
//        // get competency scores
//        Map<String, List<SessionAnchorScore>> meetingScore = sessionDuringService.listMeetingAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, List<SessionAnchorScore>> inBasketScore = sessionDuringService.listInBasketAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, SessionAnchorScoreType> competencyScores = calibrationHandler.generateAnchorScore(meetingScore, inBasketScore);
//        modelAndView.addObject("competencyScores", competencyScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        SessionReport sessionReport = sessionDuringService.loadSessionReport(session, delegate);
        modelAndView.addObject("sessionReport", sessionReport);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting("submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/financial-management", method = RequestMethod.GET)
    public ModelAndView fm(@Secure Login login,
                             @PathVariable("sessionId") Long sessionId,
                             @PathVariable("calibrationId") Long calibrationId,
                             @RequestParam(name = "subgroup", required = false) String subgroup) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-financial-management");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        SessionCalibrationCompetency sessionCalibrationCompetency = sessionDuringService.loadSessionCalibrationCompetency(sessionCalibration, "Financial Management");
        modelAndView.addObject("sessionCalibrationCompetency", sessionCalibrationCompetency);
        
        // list sessionCalibrationAnchorScore
        List<SessionCalibrationAnchorScore> sessionCalibrationAnchorScores = sessionDuringService.listCalibrationAnchorScore(sessionCalibrationCompetency);
        modelAndView.addObject("sessionCalibrationAnchorScores", sessionCalibrationAnchorScores);
        
        Session session = sessionCalibration.getSession();
        modelAndView.addObject("session", session);

        modelAndView.addObject("leadAssessor", sessionCalibration.getLeadAssessor());
        modelAndView.addObject("peerAssessor", sessionCalibration.getPeerAssessor());
        
        Delegate delegate = sessionCalibration.getDelegate();
        modelAndView.addObject("delegate", delegate);
        
        // list meeting's anchor score
        Map<String, List<SessionAnchorScore>> meetingScores = sessionDuringService.listMeetingAnchorScores(session, delegate, "Financial Management");
        modelAndView.addObject("meetingScores", meetingScores);
        modelAndView.addObject("ownerMeetingScore", sessionDuringService.generateMeetingScore(meetingScores.get("Owner Meeting")));
        
        // list inBasket's anchor score
        List<SessionAnchorScore> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, delegate, "Financial Management");
        modelAndView.addObject("inBasketScores", inBasketScores);
        modelAndView.addObject("inBasketScore", sessionDuringService.generateMeetingScore(inBasketScores));
        
//        // list meeting's anchor score
//        Map<String, Map<String, Map<String, SessionAnchorScore>>> meetingScores = sessionDuringService.listMeetingAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("meetingScores", meetingScores);
//        
//        // list inBasket's anchor score
//        Map<String, Map<String, SessionAnchorScore>> inBasketScores = sessionDuringService.listInBasketAnchorScore(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        modelAndView.addObject("inBasketScores", inBasketScores);
//        
//        // get competency scores
//        Map<String, List<SessionAnchorScore>> meetingScore = sessionDuringService.listMeetingAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, List<SessionAnchorScore>> inBasketScore = sessionDuringService.listInBasketAnchorScores(session, new Assessor[]{sessionCalibration.getLeadAssessor(), sessionCalibration.getPeerAssessor()}, delegate, "Financial Management");
//        Map<String, SessionAnchorScoreType> competencyScores = calibrationHandler.generateAnchorScore(meetingScore, inBasketScore);
//        modelAndView.addObject("competencyScores", competencyScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        SessionReport sessionReport = sessionDuringService.loadSessionReport(session, delegate);
        modelAndView.addObject("sessionReport", sessionReport);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param sessionCalibrationCompetency
     * @param strong
     * @param weak
     * @param taskName
     * @param nextCompetency
     * @param calibrationScore
     * @param locale
     * @return
     */
    @RequestMapping(value = "/{calibrationId}/competency-submit" , method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody HttpResult onCompetencySubmit(@Secure Login login, @PathVariable("sessionId") Long sessionId,
                                                       @Preloading("competencyId") SessionCalibrationCompetency sessionCalibrationCompetency,
                                                       @RequestParam("strong") List<Long> strong,
                                                       @RequestParam("weak") List<Long> weak,
                                                       @RequestParam("taskName") String taskName,
                                                       @RequestParam("nextCompetency") String nextCompetency,
                                                       CalibrationScore calibrationScore,
                                                       @SessionAttribute(name = "ihg_locale", required = false) String locale) {
        
        HttpResult httpResult = new HttpResult();
        
        try {
            
            // load sessionTask
            SessionCalibration sessionCalibration = sessionCalibrationCompetency.getSessionCalibration();
            SessionTask sessionTask = sessionTaskService.load(sessionCalibration.getSession(), sessionCalibration.getLeadAssessor(), sessionCalibration.getDelegate(), Type.ASSESSOR, taskName);
            
            sessionDuringService.competencySubmit(sessionCalibrationCompetency, calibrationScore.getAnchorScores(), strong, weak, sessionTask);
            
            String url = "/sessions/" + sessionId + "/peer-calibrations";
            if(!StringUtils.equalsIgnoreCase(nextCompetency, "calibration")) {
                url = url + "/" + sessionCalibration.getId() + "/" + nextCompetency;
            } 
            httpResult.success().data("url", url).message(Constants.LOCALE_EN_US.equals(locale) ? Constants.SUBMIT_SUCCESS_US : Constants.SUBMIT_SUCCESS_CN);
            
        } catch (Exception e) {
            logger.error("#onCompetencySubmit() - exception=[{}]", e);
            httpResult.fail("500").message(Constants.LOCALE_EN_US.equals(locale) ? Constants.SUBMIT_FAIL_US : Constants.SUBMIT_FAIL_CN);
        }
        
        return httpResult;
        
    }
    
    /**
     * 
     * @param login
     * @param calibrationId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/exercise-notes", method = RequestMethod.GET)
    public ModelAndView allExerciseNotes(@Secure Login login,
                                         @PathVariable("calibrationId") Long calibrationId) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-exercise-notes");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("delegate", sessionCalibration.getDelegate());
        
        Map<String, List<SessionCompetencyScore>> competencyScores = sessionDuringService.listSessionCompetencyScore(sessionCalibration.getSession(), sessionCalibration.getDelegate());
        modelAndView.addObject("competencyScores", competencyScores);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param calibrationId
     * @param competencyId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/competencies/{competencyId}/exercise-notes", method = RequestMethod.GET)
    public ModelAndView exerciseNotes(@Secure Login login,
                                      @PathVariable("calibrationId") Long calibrationId,
                                      @PathVariable("competencyId") Long competencyId) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-exercise-note");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("delegate", sessionCalibration.getDelegate());
        
        SessionCalibrationCompetency competency = sessionDuringService.loadSessionCalibrationCompetency(competencyId);
        modelAndView.addObject("competency", competency);
        
        String[] competencyNames = new String[]{"Guest Meeting "+competency.getName(), "Colleague Meeting "+competency.getName(), "GM Meeting "+competency.getName(), "In-basket "+competency.getName()};
        Map<String, SessionCompetencyScore> competencyScores = sessionDuringService.listSessionCompetencyScore(competencyNames, sessionCalibration.getSession(), sessionCalibration.getDelegate());
        modelAndView.addObject("competencyScores", competencyScores);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/achievement/{achievementId}", method = RequestMethod.GET)
    public ModelAndView achievementView(@Secure Login login,
                                    @PathVariable("sessionId") Long sessionId,
                                    @PathVariable("calibrationId") Long calibrationId) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-achievement-view");
        
        modelAndView.addObject("id", sessionId);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/change/{changeId}", method = RequestMethod.GET)
    public ModelAndView changeView(@Secure Login login,
                                    @PathVariable("sessionId") Long sessionId) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-change-view");
        
        modelAndView.addObject("id", sessionId);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/development/{developmentId}", method = RequestMethod.GET)
    public ModelAndView developmentView(@Secure Login login,
                                        @PathVariable("sessionId") Long sessionId) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-development-view");
        
        modelAndView.addObject("id", sessionId);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/cooperation/{cooperationId}", method = RequestMethod.GET)
    public ModelAndView cooperationView(@Secure Login login,
                                    @PathVariable("sessionId") Long sessionId) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-cooperation-view");
        
        modelAndView.addObject("id", sessionId);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/management/{managementId}", method = RequestMethod.GET)
    public ModelAndView managementView(@Secure Login login,
                                    @PathVariable("sessionId") Long sessionId) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-management-view");
        
        modelAndView.addObject("id", sessionId);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/brand-hearted/{brandHeartedId}", method = RequestMethod.GET)
    public ModelAndView brandHeartedView(@Secure Login login,
                                         @PathVariable("sessionId") Long sessionId) {

        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-brand-hearted-view");
        
        modelAndView.addObject("id", sessionId);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/overall-advantage-disadvantage", method = RequestMethod.GET)
    public ModelAndView overall(@Secure Login login,
                                @PathVariable("sessionId") Long sessionId,
                                @PathVariable("calibrationId") Long calibrationId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-overall-advantage-disadvantage");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        List<SessionCalibrationCompetency> sessionCalibrationCompetencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibration);
        modelAndView.addObject("sessionCalibrationCompetencies", sessionCalibrationCompetencies);
        
        // list strength and development needs anchorScore
        Map<String, Map<String, List<SessionCalibrationAnchorScore>>> anchorScores = sessionDuringService.listSessionCalibrationAnchorScore(sessionCalibrationCompetencies);
        modelAndView.addObject("anchorScores", anchorScores);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @param subgroup
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/overall-advantage-disadvantage-choose", method = RequestMethod.GET)
    public ModelAndView overallChoose(@Secure Login login,
                                      @PathVariable("sessionId") Long sessionId,
                                      @PathVariable("calibrationId") Long calibrationId,
                                      @RequestParam(name = "subgroup", required = false) String subgroup) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-overall-advantage-disadvantage-choose");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        List<SessionCalibrationCompetency> sessionCalibrationCompetencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibration);
        modelAndView.addObject("sessionCalibrationCompetencies", sessionCalibrationCompetencies);
        
        Map<String, SessionCalibrationCompetency> competency = CollectionUtils.constructMapValue(sessionCalibrationCompetencies, "name");
        modelAndView.addObject("competency", competency);
        
        // list strength and development needs anchorScore
        Map<String, List<SessionCalibrationAnchorScore>> strongAnchorScores = sessionDuringService.listSessionCalibrationAnchorScores(sessionCalibrationCompetencies, true);
        Map<String, List<CalibrationAnchorScoreMapper>> strongResult = new HashMap<String, List<CalibrationAnchorScoreMapper>>();
        for(String key : strongAnchorScores.keySet() ) {
            List<CalibrationAnchorScoreMapper> mappers = new ArrayList<CalibrationAnchorScoreMapper>();
            for(SessionCalibrationAnchorScore score : strongAnchorScores.get(key)) {
                mappers.add(new CalibrationAnchorScoreMapper(score));
            }
            strongResult.put(key, mappers);
        }
        
        Map<String, List<SessionCalibrationAnchorScore>> weakAnchorScores = sessionDuringService.listSessionCalibrationAnchorScores(sessionCalibrationCompetencies, false);
        Map<String, List<CalibrationAnchorScoreMapper>> weakResult = new HashMap<String, List<CalibrationAnchorScoreMapper>>();
        for(String key : weakAnchorScores.keySet() ) {
            List<CalibrationAnchorScoreMapper> mappers = new ArrayList<CalibrationAnchorScoreMapper>();
            for(SessionCalibrationAnchorScore score : weakAnchorScores.get(key)) {
                mappers.add(new CalibrationAnchorScoreMapper(score));
            }
            weakResult.put(key, mappers);
        }
        
        SessionCalibrationComment comment = sessionDuringService.loadSessionCalibrationComment(sessionCalibration);
        modelAndView.addObject("comment", comment);
        
        modelAndView.addObject("strongAnchorScores", strongResult);
        modelAndView.addObject("weakAnchorScores", weakResult);
        modelAndView.addObject("id", sessionId);
        modelAndView.addObject("subgroup", subgroup);
        
        return modelAndView;
        
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @param comment
     * @param locale
     * @return
     */
    @RequestMapping(path = "/{calibrationId}/overall-advantage-disadvantage-choose", method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody HttpResult onOverallChoose(@Secure Login login,
                                      @PathVariable("sessionId") Long sessionId,
                                      @PathVariable("calibrationId") Long calibrationId,
                                      @Preloading("id") SessionCalibrationComment comment,
                                      @SessionAttribute(name = "ihg_locale", required = false) String locale) {
        
        HttpResult httpResult = new HttpResult();
        
        try {
            
            SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
            SessionTask sessionTask = sessionTaskService.load(sessionCalibration.getSession(), sessionCalibration.getLeadAssessor(), sessionCalibration.getDelegate(), Type.ASSESSOR, "Peer Calibration Comments");
            
            sessionDuringService.commentChoose(comment, sessionTask);
            
            httpResult.success().message(Constants.LOCALE_EN_US.equals(locale) ? Constants.SUBMIT_SUCCESS_US : Constants.SUBMIT_SUCCESS_CN);
            
        } catch (Exception e) {
            logger.error("#onOverallChoose() - exception=[{}]", e);
            httpResult.fail("500").message(Constants.LOCALE_EN_US.equals(locale) ? Constants.SUBMIT_FAIL_US : Constants.SUBMIT_FAIL_CN);
        }
        
        return httpResult;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @param subgroup
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/overall-advantage-disadvantage-submit", method = RequestMethod.GET)
    public ModelAndView overallSubmit(@Secure Login login,
                                      @PathVariable("sessionId") Long sessionId,
                                      @PathVariable("calibrationId") Long calibrationId,
                                      @RequestParam(name = "subgroup", required = false) String subgroup) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-overall-advantage-disadvantage-submit");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationCompetency
        List<SessionCalibrationCompetency> sessionCalibrationCompetencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibration);
        modelAndView.addObject("sessionCalibrationCompetencies", sessionCalibrationCompetencies);
        
        Map<String, SessionCalibrationCompetency> competency = CollectionUtils.constructMapValue(sessionCalibrationCompetencies, "name");
        modelAndView.addObject("competency", competency);
        
        // list strength and development needs anchorScore
        Map<String, List<SessionCalibrationAnchorScore>> strongAnchorScores = sessionDuringService.listSessionCalibrationAnchorScores(sessionCalibrationCompetencies, true);
        Map<String, List<CalibrationAnchorScoreMapper>> strongResult = new HashMap<String, List<CalibrationAnchorScoreMapper>>();
        for(String key : strongAnchorScores.keySet() ) {
            List<CalibrationAnchorScoreMapper> mappers = new ArrayList<CalibrationAnchorScoreMapper>();
            for(SessionCalibrationAnchorScore score : strongAnchorScores.get(key)) {
                mappers.add(new CalibrationAnchorScoreMapper(score));
            }
            strongResult.put(key, mappers);
        }
        
        Map<String, List<SessionCalibrationAnchorScore>> weakAnchorScores = sessionDuringService.listSessionCalibrationAnchorScores(sessionCalibrationCompetencies, false);
        Map<String, List<CalibrationAnchorScoreMapper>> weakResult = new HashMap<String, List<CalibrationAnchorScoreMapper>>();
        for(String key : weakAnchorScores.keySet() ) {
            List<CalibrationAnchorScoreMapper> mappers = new ArrayList<CalibrationAnchorScoreMapper>();
            for(SessionCalibrationAnchorScore score : weakAnchorScores.get(key)) {
                mappers.add(new CalibrationAnchorScoreMapper(score));
            }
            weakResult.put(key, mappers);
        }
        
        SessionCalibrationComment comment = sessionDuringService.loadSessionCalibrationComment(sessionCalibration);
        modelAndView.addObject("comment", comment);
        
        modelAndView.addObject("strongAnchorScores", strongResult);
        modelAndView.addObject("weakAnchorScores", weakResult);
        modelAndView.addObject("id", sessionId);
        modelAndView.addObject("subgroup", subgroup);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @param comment
     * @param choose
     * @param chooseComment
     * @param locale
     * @return
     */
    @RequestMapping(path = "/{calibrationId}/overall-advantage-disadvantage-submit", method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody HttpResult onOverallSubmit(@Secure Login login,
                                      @PathVariable("sessionId") Long sessionId,
                                      @PathVariable("calibrationId") Long calibrationId,
                                      @Preloading("id") SessionCalibrationComment comment,
                                      @RequestParam("choose") List<String> choose,
                                      @RequestParam("chooseComment") List<String> chooseComment,
                                      @SessionAttribute(name = "ihg_locale", required = false) String locale) {
        
        HttpResult httpResult = new HttpResult();
        
        try {
            
            SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
            SessionTask sessionTask = sessionTaskService.load(sessionCalibration.getSession(), sessionCalibration.getLeadAssessor(), sessionCalibration.getDelegate(), Type.ASSESSOR, "Peer Calibration Comments");
            
            sessionDuringService.commentSubmit(comment, choose, chooseComment, sessionTask);
            
            httpResult.success().message(Constants.LOCALE_EN_US.equals(locale) ? Constants.SUBMIT_SUCCESS_US : Constants.SUBMIT_SUCCESS_CN);
            
        } catch (Exception e) {
            logger.error("#onOverallSubmit() - exception=[{}]", e);
            httpResult.fail("500").message(Constants.LOCALE_EN_US.equals(locale) ? Constants.SUBMIT_FAIL_US : Constants.SUBMIT_FAIL_CN);
        }
        
        return httpResult;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/gather", method = RequestMethod.GET)
    public ModelAndView gather(@Secure Login login,
                                       @PathVariable("sessionId") Long sessionId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-gather");
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/recommendation-summary", method = RequestMethod.GET)
    public ModelAndView recommendation(@Secure Login login,
                                       @PathVariable("sessionId") Long sessionId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-recommendation-summary");
        
        modelAndView.addObject("type", "peer-achievement");
        modelAndView.addObject("id", sessionId);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @param subgroup
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/overall-comments", method = RequestMethod.GET)
    public ModelAndView overallComments(@Secure Login login,
                                       @PathVariable("sessionId") Long sessionId,
                                       @PathVariable("calibrationId") Long calibrationId,
                                       @RequestParam(name = "subgroup", required = false) String subgroup) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-overall-comments");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        // load sessionCalibrationRecommendation
        SessionCalibrationRecommendation sessionCalibrationRecommendation = sessionDuringService.loadSessionCalibrationRecommendation(sessionCalibration);
        modelAndView.addObject("sessionCalibrationRecommendation", sessionCalibrationRecommendation);
        
        modelAndView.addObject("session", sessionCalibration.getSession());
        modelAndView.addObject("subgroup", subgroup);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param calibrationId
     * @param recommendation
     * @return
     */
    @RequestMapping(value = "/{calibrationId}/recommendation-submit" , method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody HttpResult onRecommendationSubmit(@Secure Login login,
                                                           @PathVariable("calibrationId") Long calibrationId,
                                                           SessionCalibrationRecommendation recommendation) {
        
        HttpResult httpResult = new HttpResult();
        
        try {
            
            SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
            SessionTask sessionTask = sessionTaskService.load(sessionCalibration.getSession(), sessionCalibration.getLeadAssessor(), sessionCalibration.getDelegate(), Type.ASSESSOR, "Peer Calibration Recommendation");
            
            sessionDuringService.recommendationSubmit(sessionCalibration, recommendation, sessionTask);
            
            httpResult.success().message("Submit Successful");
            
        } catch (Exception e) {
            logger.error("#onRecommendationSubmit() - exception=[{}]", e);
            httpResult.fail("500").message("Failed");
            
        }
        return httpResult;
    }
    
    /**
     * list exercise summary 
     * 
     * @param login
     * @param calibrationId
     * @return
     */
    @RequestMapping(value = "/{calibrationId}/exercises", method = RequestMethod.GET)
    public ModelAndView listSessionExercise(@Secure Login login, @PathVariable("calibrationId") Long calibrationId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-exercise-list");
        
        SessionCalibration calibration = sessionDuringService.loadSessionCalibration(calibrationId);
        List<String> names = Arrays.asList("Guest Meeting Scoring", "Colleague Meeting Scoring", "Owner Meeting Scoring", "OLT Meeting Scoring");
        
        Map<String, SessionExercise> exerciseMap = sessionDuringService.listSessionExercise(calibration.getSession(), calibration.getDelegate(), names);
        modelAndView.addObject("exerciseMap", exerciseMap);
        
        return modelAndView;
        
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @param subgroup
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/report-writing", method = RequestMethod.GET)
    public ModelAndView reportWriting(@Secure Login login,
                                      @PathVariable("sessionId") Long sessionId,
                                      @PathVariable("calibrationId") Long calibrationId,
                                      @RequestParam(name = "subgroup", required = false) String subgroup) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-report-writing");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        List<SessionCalibrationCompetency> competencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibration);
        Map<String, SessionCalibrationCompetency> competenciesMap = CollectionUtils.constructMapValue(competencies, "name");
        modelAndView.addObject("competencies", competencies);
        modelAndView.addObject("competenciesMap", competenciesMap);
        
        SessionCalibrationComment comment = sessionDuringService.loadSessionCalibrationComment(sessionCalibration);
        modelAndView.addObject("comment", comment);
        
        SessionCalibrationRecommendation recommendation = sessionDuringService.loadSessionCalibrationRecommendation(sessionCalibration);
        modelAndView.addObject("recommendation", recommendation);
        
        SessionTask sessionTask = sessionTaskService.load(sessionCalibration.getSession(), sessionCalibration.getLeadAssessor(), sessionCalibration.getDelegate(), Type.ASSESSOR, "Peer Calibration Report");
        modelAndView.addObject("sessionTask", sessionTask);
        
        // load sessionCalibrationCompetency
        List<SessionCalibrationCompetency> sessionCalibrationCompetencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibration);
        modelAndView.addObject("sessionCalibrationCompetencies", CollectionUtils.constructMapValue(sessionCalibrationCompetencies, "name"));
        
        // list strength and development needs anchorScore
        Map<String, Map<String, List<SessionCalibrationAnchorScore>>> anchorScores = sessionDuringService.listSessionCalibrationAnchorScore(sessionCalibrationCompetencies);
        modelAndView.addObject("anchorScores", anchorScores);
        
        modelAndView.addObject("subgroup", subgroup);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param calibrationId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-two")
    @RequestMapping(path = "/{calibrationId}/report-view", method = RequestMethod.GET)
    public ModelAndView reportView(@Secure Login login,
                                      @PathVariable("sessionId") Long sessionId,
                                      @PathVariable("calibrationId") Long calibrationId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/peer-calibration-report-view");
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(calibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        List<SessionCalibrationCompetency> competencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibration);
        modelAndView.addObject("competencies", competencies);
        
        SessionCalibrationComment comment = sessionDuringService.loadSessionCalibrationComment(sessionCalibration);
        modelAndView.addObject("comment", comment);
        
        // load sessionCalibrationCompetency
        List<SessionCalibrationCompetency> sessionCalibrationCompetencies = sessionDuringService.listSessionCalibrationCompetency(sessionCalibration);
        modelAndView.addObject("sessionCalibrationCompetencies", sessionCalibrationCompetencies);
        
        // list strength and development needs anchorScore
        Map<String, Map<String, List<SessionCalibrationAnchorScore>>> anchorScores = sessionDuringService.listSessionCalibrationAnchorScore(sessionCalibrationCompetencies);
        modelAndView.addObject("anchorScores", anchorScores);
        
        SessionCalibrationRecommendation recommendation = sessionDuringService.loadSessionCalibrationRecommendation(sessionCalibration);
        modelAndView.addObject("recommendation", recommendation);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param delegateId
     * @return
     */
    @RequestMapping(path = "/career-work", method = RequestMethod.GET)
    public ModelAndView careerWorkbook(@Secure Login login, @PathVariable("sessionId") Long sessionId,
                                       @RequestParam("delegate") Long delegateId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/career-workbook-view");
        
        Delegate delegate = delegateService.load(Delegate.class, delegateId);
        modelAndView.addObject("delegate", delegate);
        
        // 1. load session
        Session session = sessionService.load(Session.class, sessionId);
        modelAndView.addObject("session", session);
        
        // 2. list work record
        List<DelegateWrokRecord> delegateWrokRecords =  careerWorkService.listWorkRecord(delegate);
        modelAndView.addObject("delegateWrokRecords", delegateWrokRecords);
        
        // 3. load work experience
        DelegateWrokExperience delegateWrokExperience = careerWorkService.loadWorkExperience(delegate);
        modelAndView.addObject("delegateWrokExperience", delegateWrokExperience);
        
        // 4. list work training
        List<DelegateWrokTraining> delegateWrokTrainings = careerWorkService.listWorkTraining(delegate);
        modelAndView.addObject("delegateWrokTrainings", delegateWrokTrainings);
        
        // 5. list work education
        List<DelegateWorkEducation> delegateWorkEducations = careerWorkService.listEducation(delegate);
        modelAndView.addObject("delegateWorkEducations", delegateWorkEducations);
        
        // 6. list work license
        List<DelegateWorkLicense> delegateWorkLicenses = careerWorkService.listLicense(delegate);
        modelAndView.addObject("delegateWorkLicenses", delegateWorkLicenses);
        
        // 7. load career goals
        DelegateCareerGoals delegateCareerGoals = careerWorkService.loadCareerGoals(delegate);
        modelAndView.addObject("delegateCareerGoals", delegateCareerGoals);
        
        // 8. load self reflection
        DelegateSelfReflection delegateSelfReflection = careerWorkService.loadSelfReflection(delegate);
        modelAndView.addObject("delegateSelfReflection", delegateSelfReflection);
        
        // 9. list future position
        List<DelegateWorkFuturePosition> delegateWorkFuturePositions = careerWorkService.listPosition(delegate);
        modelAndView.addObject("delegateWorkFuturePositions", delegateWorkFuturePositions);
        
        // 10. list develop activity
        List<DelegateWorkDevelopActivity> delegateWorkDevelopActivities = careerWorkService.listActivity(delegate);
        modelAndView.addObject("delegateWorkDevelopActivities", delegateWorkDevelopActivities);
        
        return modelAndView;
    }
    
    /**
     * 
     * @return
     */
    @RequestMapping(path = "/comment-example", method = RequestMethod.GET)
    public ModelAndView commentExample() {
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/calibration-recommendation-example");
        return modelAndView;
    }
    
    /**
     * 
     * @param sessionId
     * @param delegateId
     * @return
     */
    @RequestMapping(path = "/delegate-virtual-hotel", method = RequestMethod.GET)
    public ModelAndView delegateVirtual(@PathVariable("sessionId") Long sessionId, @RequestParam("delegateId") Long delegateId) {
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/delegate-virtual-hotel");
        
        Session session = sessionService.load(sessionId);
        Delegate delegate = delegateService.load(Delegate.class, delegateId);
        PreWorkAssignment preWorkAssignment = sessionTaskService.loadPreWorkAssignment(session, delegate);
        modelAndView.addObject("preWorkAssignment", preWorkAssignment);
        
        return modelAndView;
    }
    
    /**
     * 
     * @param login
     * @param sessionId
     * @param delegateId
     * @return
     */
    @RequestMapping(value = "/{id}/delegate-ib-assessment", method = RequestMethod.GET)
    public ModelAndView introduction(@Secure Login login,
                                     @PathVariable("sessionId") Long sessionId,
                                     @PathVariable("id") Long peerCalibrationId,
                                     @RequestParam("delegate") Long delegateId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/delegate-ib-assessment");
        
        Assessor assessor = assessorService.load(Assessor.class, login.getId());
        Delegate delegate = delegateService.load(Delegate.class, delegateId);
        modelAndView.addObject("delegate", delegate);
        
        Session session = sessionService.load(sessionId);
        modelAndView.addObject("session", session);
        
        SessionCalibration sessionCalibration = sessionDuringService.loadSessionCalibration(peerCalibrationId);
        modelAndView.addObject("sessionCalibration", sessionCalibration);
        
        SessionInBasket sessionInBasket = sessionDuringService.loadSessionInbasket(session, assessor, delegate, "In-basket Score");
        if(sessionInBasket == null) {
            
            SessionParticipator sessionParticipator = sessionParticipatorService.loadByAssessor(session, sessionCalibration.getLeadAssessor().getId());
            SessionParticipator peerParticipator = sessionParticipatorService.loadByAssessor(session, sessionCalibration.getLeadAssessor().getId());
            Assessor peerAssessor = assessorService.load(Assessor.class, peerParticipator.getAssessorId());
            sessionInBasket = sessionDuringService.loadSessionInbasket(session, peerAssessor, delegate, "In-basket Score");
            
        }
        
        modelAndView.addObject("sessionInBasket", sessionInBasket);
        
        Map<String, Map<String, List<SessionInBasketAnswer>>> answers = sessionDuringService.listSessionInBasketAnswer(sessionInBasket);
        modelAndView.addObject("answers", answers);
        
        return modelAndView;
    }
    
    /**
     * 
     * 
     * 
     * @param login
     * @param sessionId
     * @return
     */
    @RequestMapping(value = "/view-ced-tool" , method = RequestMethod.GET)
    public ModelAndView viewCedTool(@RequestParam("delegateId") Long delegateId, @PathVariable("sessionId") Long sessionId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/peer-calibration/owner-meeting-delegate-ced-tool");
        
        Delegate delegate = delegateService.load(Delegate.class, delegateId);
        Map<String, DelegateAttribute> attrs = delegateService.listAttribute(delegate);
        if(!MapUtils.isEmpty(attrs)) {
            modelAndView.addObject("cedTool", attrs.get("ced-tool"));
        }
        
        modelAndView.addObject("sessionId", sessionId);
        
        return modelAndView;
        
    }
    
}
